package com.isunland.managesystem.ui;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.isunland.managesystem.R;
import com.isunland.managesystem.entity.SPlanKindManager;
import java.util.List;

/**
 * Created by wangyanan on 2016/8/29.
 * 工作类别适配器类
 */
public class PlanKindAdapter extends ArrayAdapter<SPlanKindManager.PlanKind> {

  /**
   * ViewHolder class for layout.<br />
   * <br />
   * Auto-created on 2016-02-17 15:12:50 by Android Layout Finder
   * (http://www.buzzingandroid.com/tools/android-layout-finder)
   */
  private static class ViewHolder {
    public final LinearLayout rootView;
    public final TextView tvNameSearchPerson;
    public final TextView tvDepartmentSearchPerson;

    private ViewHolder(LinearLayout rootView, TextView tvNameSearchPerson,
        TextView tvDepartmentSearchPerson) {
      this.rootView = rootView;
      this.tvNameSearchPerson = tvNameSearchPerson;
      this.tvDepartmentSearchPerson = tvDepartmentSearchPerson;
    }

    public static ViewHolder create(LinearLayout rootView) {
      TextView tvNameSearchPerson = (TextView) rootView.findViewById(R.id.tv_name_searchPerson);
      TextView tvDepartmentSearchPerson =
          (TextView) rootView.findViewById(R.id.tv_department_searchPerson);
      return new ViewHolder(rootView, tvNameSearchPerson, tvDepartmentSearchPerson);
    }
  }

  @Override public View getView(int position, View convertView, ViewGroup parent) {
    final ViewHolder vh;
    if (convertView == null) {
      View view = mInflater.inflate(R.layout.adapter_search_person, parent, false);
      vh = ViewHolder.create((LinearLayout) view);
      view.setTag(vh);
    } else {
      vh = (ViewHolder) convertView.getTag();
    }

    SPlanKindManager.PlanKind item = getItem(position);

    //Bind your data to the views here
    vh.tvNameSearchPerson.setText(item.getPlanKindName());
    //        vh.tvDepartmentSearchPerson.setVisibility(View.GONE);
    //        vh.tvDepartmentSearchPerson.setText(item.getPlanKindType());
    return vh.rootView;
  }

  private LayoutInflater mInflater;

  // Constructors
  public PlanKindAdapter(Context context, List<SPlanKindManager.PlanKind> objects) {
    super(context, 0, objects);
    this.mInflater = LayoutInflater.from(context);
  }

  public PlanKindAdapter(Context context, SPlanKindManager.PlanKind[] objects) {
    super(context, 0, objects);
    this.mInflater = LayoutInflater.from(context);
  }

  @Override public boolean isEmpty() {
    // Auto-generated method stub
    return false;
  }
}
